﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.Workshop;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.Workshop
{
    public class WorkshopContentService: IService<WorkshopContent>
    {
        private readonly GenericRepository<WorkshopContent> _workshopContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public WorkshopContentService(IUnitOfWork unitOfWork, GenericRepository<WorkshopContent> workshopContentRepository)
        {
            this._workshopContentRepository = workshopContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<WorkshopContent> GetAllElements()
        {
            return _workshopContentRepository.GetAll();
        }

        public WorkshopContent GetElementById(int id)
        {
            return _workshopContentRepository.GetById(id);
        }

        public void CreateElement(WorkshopContent entity)
        {
            _workshopContentRepository.Insert(entity);
        }

        public void UpdateElement(WorkshopContent entity)
        {
            _workshopContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _workshopContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
